<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>~/Projects/Java/CS222/Examples/src/Test2.java.html</title>
<meta name="Generator" content="Vim/7.1">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000"><font face="monospace">
<font color="#0000ff">/**</font><br>
<font color="#0000ff">&nbsp;*</font><font color="#6a5acd">&nbsp;Test2.java</font><br>
<font color="#0000ff">&nbsp;*</font><font color="#6a5acd">&nbsp;Overloaded main methods...</font><font color="#0000ff">&nbsp;Because we can...</font><br>
<font color="#0000ff">&nbsp;*</font><br>
<font color="#0000ff">&nbsp;* </font><font color="#6a5acd">@author</font><font color="#0000ff">&nbsp;&nbsp;John Thomason</font><br>
<font color="#0000ff">&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;Date: Nov 9, 2008</font><br>
<font color="#0000ff">&nbsp;*&nbsp;&nbsp;Course: CS222 Java Programming II</font><br>
<font color="#0000ff">&nbsp;* Seminar: 2</font><br>
<font color="#0000ff">&nbsp;*&nbsp;&nbsp;Assign: n/a</font><br>
<font color="#0000ff">&nbsp;*/</font><br>
<br>
<font color="#0000ff">/**</font><br>
<font color="#0000ff">&nbsp;*</font><font color="#6a5acd">&nbsp;Test2 Class</font><br>
<font color="#0000ff">&nbsp;*</font><font color="#6a5acd">&nbsp;- Description</font><br>
<font color="#6a5acd">&nbsp;</font><font color="#0000ff">*/</font><br>
<font color="#2e8b57"><b>public</b></font>&nbsp;<font color="#2e8b57"><b>class</b></font>&nbsp;Test2 {<br>
<br>
&nbsp;&nbsp;<font color="#0000ff">/**</font><br>
<font color="#0000ff">&nbsp;&nbsp; *</font><font color="#6a5acd">&nbsp;Application Entry Point</font><br>
<font color="#0000ff">&nbsp;&nbsp; </font><font color="#0000ff">* </font><font color="#6a5acd">@param</font><font color="#008b8b">&nbsp;args</font><font color="#0000ff">&nbsp;The command line arguments</font><br>
<font color="#0000ff">&nbsp;&nbsp; */</font><br>
&nbsp;&nbsp;<font color="#2e8b57"><b>public</b></font>&nbsp;<font color="#2e8b57"><b>static</b></font>&nbsp;<font color="#2e8b57"><b>void</b></font>&nbsp;main(String[]&nbsp;joe)&nbsp;{<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;prt(<font color="#ff00ff">&quot;The main(String[] args) method</font><font color="#6a5acd">\n</font><font color="#ff00ff">&quot;</font>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if</b></font>(&nbsp;joe.length &gt; <font color="#ff00ff">0</font>&nbsp;){<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>for</b></font>(&nbsp;String s: joe ){<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prt(s);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<font color="#0000ff">//foreach</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;prt(); prt();<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;Integer[]&nbsp;ints = {<font color="#ff00ff">1</font>,<font color="#ff00ff">2</font>,<font color="#ff00ff">3</font>,<font color="#ff00ff">4</font>,<font color="#ff00ff">5</font>,<font color="#ff00ff">6</font>,<font color="#ff00ff">7</font>,<font color="#ff00ff">8</font>,<font color="#ff00ff">9</font>,<font color="#ff00ff">0</font>};<br>
&nbsp;&nbsp;&nbsp;&nbsp;main(ints);&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff">//Call to overloaded main(Integer[])</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;Double[]&nbsp;&nbsp;dubs = {<font color="#ff00ff">1.2</font>,<font color="#ff00ff">2.3</font>,<font color="#ff00ff">3.4</font>,<font color="#ff00ff">4.5</font>,<font color="#ff00ff">5.6</font>,<font color="#ff00ff">6.7</font>,<font color="#ff00ff">8.9</font>,<font color="#ff00ff">9.0</font>,<font color="#ff00ff">0.1</font>};<br>
&nbsp;&nbsp;&nbsp;&nbsp;main(dubs);&nbsp;&nbsp;&nbsp;&nbsp; <font color="#0000ff">//Call to overloaded main(Double[])</font><br>
<br>
&nbsp;&nbsp;}<font color="#0000ff">//main()</font><br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;<font color="#0000ff">/**</font><br>
<font color="#0000ff">&nbsp;&nbsp; *</font><font color="#6a5acd">&nbsp;Overloaded main()</font><br>
<font color="#0000ff">&nbsp;&nbsp; </font><font color="#0000ff">* </font><font color="#6a5acd">@param</font><font color="#008b8b">&nbsp;args</font><font color="#0000ff">&nbsp;Array of Integers</font><br>
<font color="#0000ff">&nbsp;&nbsp; */</font><br>
&nbsp;&nbsp;<font color="#2e8b57"><b>public</b></font>&nbsp;<font color="#2e8b57"><b>static</b></font>&nbsp;<font color="#2e8b57"><b>void</b></font>&nbsp;main(Integer[]&nbsp;bob){<br>
&nbsp;&nbsp;&nbsp;&nbsp;prt(<font color="#ff00ff">&quot;The main(Integer[] args) method</font><font color="#6a5acd">\n</font><font color="#ff00ff">&quot;</font>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if</b></font>(&nbsp;bob.length &gt; <font color="#ff00ff">0</font>&nbsp;){<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>for</b></font>(&nbsp;Integer i: bob ){<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prt(i);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<font color="#0000ff">//foreach</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;prt(); prt();&nbsp;&nbsp; <br>
&nbsp;&nbsp;}<font color="#0000ff">//main()</font><br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;<font color="#0000ff">/**</font><br>
<font color="#0000ff">&nbsp;&nbsp; *</font><font color="#6a5acd">&nbsp;Overloaded main()</font><br>
<font color="#0000ff">&nbsp;&nbsp; </font><font color="#0000ff">* </font><font color="#6a5acd">@param</font><font color="#008b8b">&nbsp;args</font><font color="#0000ff">&nbsp;Array of Doubles</font><br>
<font color="#0000ff">&nbsp;&nbsp; */</font><br>
&nbsp;&nbsp;<font color="#2e8b57"><b>public</b></font>&nbsp;<font color="#2e8b57"><b>static</b></font>&nbsp;<font color="#2e8b57"><b>void</b></font>&nbsp;main(Double[]&nbsp;jim){<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;prt(<font color="#ff00ff">&quot;The main(Double[] args) method</font><font color="#6a5acd">\n</font><font color="#ff00ff">&quot;</font>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if</b></font>(&nbsp;jim.length &gt; <font color="#ff00ff">0</font>&nbsp;){<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>for</b></font>(&nbsp;Double d: jim ){<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prt(d);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<font color="#0000ff">//foreach</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;}<br>
&nbsp;&nbsp;&nbsp;&nbsp;prt(); prt();<br>
&nbsp;&nbsp;}<font color="#0000ff">//main()</font><br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;<font color="#0000ff">/**</font><br>
<font color="#0000ff">&nbsp;&nbsp; *</font><font color="#6a5acd">&nbsp;Overloaded prt methods</font><br>
<font color="#6a5acd">&nbsp;&nbsp; </font><font color="#0000ff">*/</font><br>
&nbsp;&nbsp;<font color="#2e8b57"><b>public</b></font>&nbsp;<font color="#2e8b57"><b>static</b></font>&nbsp;<font color="#2e8b57"><b>void</b></font>&nbsp;prt(String s){<br>
&nbsp;&nbsp;&nbsp;&nbsp;System.out.printf(<font color="#ff00ff">&quot;%s &quot;</font>, s);<br>
&nbsp;&nbsp;}<font color="#0000ff">//prt(String)</font><br>
<br>
&nbsp;&nbsp;<font color="#2e8b57"><b>public</b></font>&nbsp;<font color="#2e8b57"><b>static</b></font>&nbsp;<font color="#2e8b57"><b>void</b></font>&nbsp;prt(Integer i){<br>
&nbsp;&nbsp;&nbsp;&nbsp;System.out.printf(<font color="#ff00ff">&quot;%d &quot;</font>, i);<br>
&nbsp;&nbsp;}<font color="#0000ff">//prt(Integer)</font><br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;<font color="#2e8b57"><b>public</b></font>&nbsp;<font color="#2e8b57"><b>static</b></font>&nbsp;<font color="#2e8b57"><b>void</b></font>&nbsp;prt(Double d){<br>
&nbsp;&nbsp;&nbsp;&nbsp;System.out.printf(<font color="#ff00ff">&quot;%.2f &quot;</font>, d);<br>
&nbsp;&nbsp;}<font color="#0000ff">//prt(Double)</font><br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;<font color="#2e8b57"><b>public</b></font>&nbsp;<font color="#2e8b57"><b>static</b></font>&nbsp;<font color="#2e8b57"><b>void</b></font>&nbsp;prt(){<br>
&nbsp;&nbsp;&nbsp;&nbsp;System.out.println();<br>
&nbsp;&nbsp;}<font color="#0000ff">//prt()</font><br>
&nbsp;&nbsp;<br>
}<font color="#0000ff">//End Test2 Class</font><br>
</font></body>
</html>
